<?php

namespace App\Admin\Actions;

use Encore\Admin\Actions\RowAction;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
use App\Models\CoursesSection;

class OrderApplyAfter extends RowAction
{
    public $name = '申请售后';

    public function handle(Model $model, Request $request)
    {
       /* try {
            $section = new CoursesSection();
            $section->courses_title = $request->input('courses_title');
            $section->courses_id = $model->id;
            $section->user_id = auth()->user()->id ?? 0;
            $file = $request->file('courses_video');
            $ext = $file->getClientOriginalExtension();
            $filename = time() . rand() . "." . $ext;
            $file->move(public_path('upload/video/'), $filename);
            $section->courses_video = 'video/' . $filename;
            $section->save();
        } catch (\Exception $e) {
            return $e->getMessage();
        }
        return $this->response()->success('添加成功!')->refresh();*/
    }

    public function form()
    {
        $this->text('courses_title', __('课程章节'))->rules('required');
        $this->file('courses_video', '章节视频')->uniqueName()->removable();
    }

}